package com.takeaway.service.serviceimpl;

import com.takeaway.const_.Const;
import com.takeaway.dao.daointerface.CartDao;
import com.takeaway.dao.daolmpl.CartDaoImpl;
import com.takeaway.pojo.Cart;
import com.takeaway.service.serviceinterface.CartService;
import java.util.List;

/**
 * @author 后台赖骏
 */
public class CartServiceImpl implements CartService {
    private static final CartDao CART_DAO = new CartDaoImpl();


    @Override
    public int addCart(int userId, int foodId, int cartNum) throws Exception {
        return CART_DAO.insert(new Cart(userId,foodId,cartNum));
    }

    @Override
    public List<Cart> checkCart(int userId) throws Exception {
        String[] checkField1 ={Const.FIELD_USERID};
        return CART_DAO.selectMore(Cart.class, checkField1, userId);
    }

    @Override
    public int deleteCart(int cartId) throws Exception {
        String[] checkField1 ={Const.FIELD_ID};
        return CART_DAO.delete(Cart.class,checkField1,cartId);
    }
}
